package Thread;

public class DeadLock {
    public static void main(String[] args) throws InterruptedException {
        Object locker1 = new Object();
        Object locker2 = new Object();
        Thread t1 = new Thread(() -> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            synchronized (locker1) {
                synchronized (locker2) {
                    ;
                }
            }
        });

        Thread t2 = new Thread(() -> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            synchronized (locker2) {
                synchronized (locker1) {
                    ;
                }
            }
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
    }
}
